package com.qingcloud.adminbackend.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qingcloud.adminbackend.entity.equipment.SysEquipmentDetailsDTO;
import com.qingcloud.adminbackend.entity.sysorg.SysOrg;
import com.qingcloud.adminbackend.entity.sysorg.SysOrgBO;
import com.qingcloud.adminbackend.entity.sysorg.SysUserOrgMgr;
import com.qingcloud.adminbackend.entity.sysorg.SysUserModuleDTO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author liyuhong
 * @since 2018-12-26
 */
public interface SysUserOrgMgrMapper extends BaseMapper<SysUserOrgMgr> {
    /**
     * 根据用户ID查询用户可以管理的客户列表
     *
     * @param userId
     */
    List<SysOrg> findAllManageOrgByUser(@Param("userId") String userId, @Param("businessType") String businessType);

    /**
     * 根据用户ID查询其下面所有可读可写的客户和分支结构
     *
     * @param userId 用户ID
     */
    List<SysOrg> findAllOrgAndChildByUser(@Param("userId") String userId, @Param("businessType") String businessType);

    /**
     * 添加用户可管理客户
     *
     * @param sysUserOrgMgr
     */
    void insertSysUserOrgMgr(@Param("sysUserOrgMgr") SysUserOrgMgr sysUserOrgMgr);

    List<SysOrgBO> findOrgMgrByUserId(@Param("userId") String userId, @Param("roleId") String roleId);

    /**
     * 我可以管理的一级客户
     * @param userId
     * @param isAdmin
     * @return
     */
    List<SysUserModuleDTO> findOrgListByUserId(@Param("userId") String userId, @Param("isAdmin")  boolean isAdmin,@Param("parameter") String parameter,@Param("businessType") String businessType);

    /**
     * 查询设备读写权限
     * @param equipmentId
     * @param userId
     * @return
     */
    SysEquipmentDetailsDTO findOrgMgrByEquipmentId(@Param("equipmentId") String equipmentId,@Param("userId") String userId);
}
